﻿using System.Collections.Generic;
using System.Linq;

namespace Shell.KnowledgeBase
{
    public class Implication
    {
        public readonly IEnumerable<Statement> Antecedents;
        public readonly Statement Consequent;

        public Implication(IEnumerable<Statement> antecedents, Statement consequent)
        {
            Antecedents = antecedents;
            Consequent = consequent;
        }

        public override string ToString()
        {
            return
                string.Join(" & ", Antecedents.Select(_ => _.ToString()))
                + " -> "
                + Consequent;
        }

        public Implication Resolve(BindingContext bindingContext)
        {
            return new Implication(
                Antecedents.Select(_ => _.Resolve(bindingContext)),
                Consequent.Resolve(bindingContext));
        }
    }
}